<!DOCTYPE html>
<html lang="zh">

<head>
  <meta charset="UTF-8">
  <meta name="page-view-size" content="1280*720">
  <link rel="stylesheet" href="styles/base.css">
  <title>熊猫部落-订单列表页面</title>
  <style>
    body {
      position: absolute;
      margin: 0;
      padding: 0;
      width: 1280px;
      height: 720px;
      background: url();
      background-color: transparent;
    }

    #tab,
    #detail {
      position: absolute;
      width: 450px;
      height: 420px;
      top: 209px;
      overflow: hidden;
    }

    #tab {
      left: 156px;
    }

    #detail {
      left: 651px;
      font-size: 26px;
      color: #fff;
      line-height: 42px;
    }

    #title {
      padding-bottom: 5px;
    }

    #tab .item {
      font-size: 28px;
      padding: 0 5px;
      height: 70px;
      line-height: 70px;
      background: url(images/order-list-bg.png) repeat;
      margin-bottom: 20px;
      text-align: center;
      color: #fff;
    }

    #tab .item.focus {
      color: #563f21;
      background: url(images/order-list-bg-focus.png) repeat;
    }

    #tab .item-view {
      height: 100%;
      position: relative;
      overflow: hidden;
    }

    #tab .item-text {
      position: relative;
      white-space: nowrap;
    }

    #tab .item.focus .item-text {
      position: absolute;
    }
  </style>
</head>

<body onload="init()" onunload="exit()">
  <div id="tab">
    <div id="tab-view" style="position: relative;"></div>
  </div>
  <div id="detail">

  </div>
</body>
<script src="js/jquery.js"></script>
<script src="config/index.js?v=1"></script>
<script src="api/index.js?v=1"></script>
<script src="js/KeyEvent.js?v=12"></script>
<script src="js/event.js?v=12"></script>
<script src="js/utli.js?v=12"></script>
<script src="js/base.js"></script>
<script>
  var obj = null;

  var index = 0;

  function init() {
    getPreFocus();
    renderBg();
    renderOrderList();
  }

  function getPreFocus() {
    var url = window.location.href;
    mediaCode = GY.getURLParameter("mediaCode", url) != "" ? GY.getURLParameter(
      "mediaCode", url) : '';
    vodId = GY.getURLParameter("vodId", url) != "" ? GY.getURLParameter(
      "vodId", url) : '';
    returnUrl = unescape(GY.getURLParameter("returnUrl", url) != "" ? GY.getURLParameter(
      "returnUrl", url) : '');
  }

  function renderBg() {
    var data = getTypeListByTypeId({
      TYPEID: '1284087959661842433'
    }).TYPEs;
    var bg = '';
    if (data.length > 0) {
      bg = data[0].typePicture[0].picPath3;
    }
    $('body').css('background-image', 'url(' + bg + ')');
  }

  function renderDetail() {
    var title = '';
    var info = '';

    if (obj[index].priceDes) {
      if (obj[index].priceDes && obj[index].description) {
        title = '<div id="title">产品资费：' + obj[index].priceDes + '</div>';
        info = '<div id="info">订购说明：' + obj[index].description + '</div>';
      }
    } else if (obj[index].price) {
      if (obj[index].price && obj[index].description) {
        title = '<div id="title">产品资费：' + obj[index].price + '</div>';
        info = '<div id="info">订购说明：' + obj[index].description + '</div>';
      }
    }



    $('#detail').html(title + info);
  }

  function renderOrderList() {
    filmDate = playFilmData({
      mediaCode: mediaCode
    });
    obj = filmDate.productObject.productList;
    var html = '';
    for (var i = 0; i < obj.length; i++) {
      html += '<div id="tab-' + i + '" class="item"><div class="item-view"><div class="item-text">' + obj[i].name +
        '</div></div></div>'
    }
    $('#tab-view').html(html);
    onFocus();
  }

  function onFocus() {
    var eFocus = $('#tab-' + index);
    eFocus.addClass('focus');
    conputeScroll(index);
    starMarquee(eFocus)
    renderDetail();
  }

  function freeFocus() {
    var eFocus = $('#tab-' + index);
    eFocus.removeClass('focus');
    stopMarquee(eFocus)
  }


  function keyDown() {
    if (index < $('.item').length - 1) {
      freeFocus();
      index++;
      onFocus();
    }
  }

  function keyUp() {
    if (index > 0) {
      freeFocus();
      index--;
      onFocus();
    }
  }

  function keyEnter() {
    // console.error(returnUrl)
    // return;
    order({
      mediaCode: mediaCode,
      ProductID: obj[index].productId,
      ReturnURL: escape(returnUrl + '&IS_ORDER=1&ORDER_ID=' + vodId + '&PRO_ID=' + obj[index].productId),
      backUrl: escape(returnUrl + '&IS_ORDER=1&ORDER_ID=' + vodId + '&PRO_ID=' + obj[index].productId)
    })
    // GY.addUrl(PANDA_PATH + '')
  }

  // 计算左侧的偏移量
  function conputeScroll(index) {
    var len = $('.item').length;
    var _diff = 5;
    if (len < _diff) return;
    var ave = Math.floor(_diff / 2);
    var height = 90;
    if (index < ave) {
      $('#tab-view').css('top', 0);
    } else if (index > (len - ave)) {
      $('#tab-view').css('top', -(len - _diff + 1) * height)
    } else {
      $('#tab-view').css('top', -(index - ave) * height)
    }
  }

  function keyBack() {
    // GY.goback();
    window.location.href = returnUrl;
  }





  function exit() {

  }
</script>


</html>